package com.blueocean_health.care.management.em;

import com.blueocean_health.care.management.common.base.string.StringUtils;

/**
 * 付款方式
 * 
 * @todo
 * @author 张亚林
 * @date 2018年8月23日 下午5:46:27
 */
public enum PayTypeEnum {
	WECHAT("6","WECHAT", "微信"), ALIPAY("5","ALIPAY", "支付宝"),;

	private String key;
	private String val;
	private String name;

	private PayTypeEnum(String key, String val,String name) {
		this.key = key;
		this.val = val;
		this.name=name;
	}

	public String getKey() {
		return key;
	}

	public String getVal() {
		return val;
	}
	
	public String getName() {
		return name;
	}

	/**
	 * 根据key值查value
	 * 
	 * @param value
	 * @return
	 */
	public static String ValOfKey(String key) {
		if (!StringUtils.isEmpty(key)) {
			PayTypeEnum[] businessModeEnums = values();
			for (PayTypeEnum businessModeEnum : businessModeEnums) {
				if (businessModeEnum.getKey().equals(key)) {
					return businessModeEnum.getVal();
				}
			}
		}
		return null;
	}
	
	/**
	 * 根据value值查key
	 * 
	 * @param value
	 * @return
	 */
	public static String KeyOfValue(String value) {
		if (!StringUtils.isEmpty(value)) {
			PayTypeEnum[] businessModeEnums = values();
			for (PayTypeEnum businessModeEnum : businessModeEnums) {
				if (businessModeEnum.getVal().equals(value)) {
					return businessModeEnum.getKey();
				}
			}
		}
		return null;
	}
	
	/**
	 * 根据key值查name
	 * 
	 * @param value
	 * @return
	 */
	public static String NameOfKey(String key) {
		if (!StringUtils.isEmpty(key)) {
			PayTypeEnum[] businessModeEnums = values();
			for (PayTypeEnum businessModeEnum : businessModeEnums) {
				if (businessModeEnum.getKey().equals(key)) {
					return businessModeEnum.getName();
				}
			}
		}
		return null;
	}



}
